{include file="public/header" /}

<div class="page">

    <form id="user_form" enctype="multipart/form-data" method="post">
        <table class="ds-default-table">
            <tbody>
                <tr class="noborder">
                    <td class="required w150"><label class="validation" for="member_name">客户编码:</label></td>
                    <td class="vatop rowform"><input type="text" value="" name="member_client" id="member_client" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w150"><label class="validation" for="member_name">三三账号:</label></td>
                    <td class="vatop rowform"><input type="text" value="" name="member_name" id="member_name" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label class="validation" for="member_password">三三密码:</label></td>
                    <td class="vatop rowform"><input type="text" id="member_password" name="member_password" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                        <td class="required"><label class="validation" >客户名称:</label></td>
                        <td class="vatop rowform"><input  name="customer_name" value="" class="txt" type="text"></td>
                        <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                        <td class="required"><label class="validation" >昵称:</label></td>
                        <td class="vatop rowform"><input  name="member_nickname" value="" class="txt" type="text"></td>
                        <td class="vatop tips"></td>
                </tr>
                
                <tr class="noborder">
                      <td class="required"><label>区域:</label></td>
                      <td><input type="hidden" name="member_address" id="member_address" ></td>
                </tr>
                <tr class="noborder" >
                    <td class="w120"><label class="" for="">地址:</label></td>
                    <td class="vatop rowform"><textarea name="member_detail_address" rows="6" class="tarea" id="store_close_info"></textarea></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                 <td class="required"><label>客户类型:</label></td>
                 <td class="vatop">
                     <label>
                         <select name="enterprise_type" id="typeid" style="width: 222px;">
                             <option value="">请选择</option>
                             {foreach name="enterprisetype_info" item="cate"}
                             <option value="{$cate.id}">{$cate.name|default=''}</option>
                             {/foreach}
                         </select>
                     </label>
                 </td>
                 <td class="vatop tips"></td>
                 </tr>
                <tr class="noborder">
                    <td class="required"><label for="member_qq">建店年份:</label></td>
                    <td class="vatop rowform">
                        <input id="start_time"  name="start_time" type="text" class="text"/>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label for="member_qq">税号:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_paragraph" name="member_paragraph" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label  class="validation" for="member_password">负责人:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_person" name="member_person" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label class="validation" for="member_password">负责人联系方式:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_person_tel" name="member_person_tel" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label class="validation" for="member_password">联系人:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="contact_name" name="contact_name" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label class="validation" for="member_password">联系人电话:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="contact_phone" name="contact_phone" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                        <td class="required w150"><label class="" >用户头像:</label></td>
                        <td class="vatop rowform"><input  name="file" id='upload_img'  type="file">
                         <input type="hidden" name="portrait" id='portrait'>
                        </td>
                        <td class="vatop tips">请上传后缀名为：*.jpeg *.jpg *.png 的文件</td>
                    </tr>
                <!-- <tr class="noborder">
                    <td class="required"><label class="validation" for="member_email">{$Think.lang.member_index_email}:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_email" name="member_email" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr> -->
               <!--  <tr class="noborder">
                    <td class="required"><label for="member_truename">{$Think.lang.member_index_true_name}:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_truename" name="member_truename" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr> -->
                <tr class="noborder">
                    <td class="required"><label> {$Think.lang.member_edit_sex}:</label></td>
                    <td class="vatop rowform">
                        <label class="radio-label">
                            <i  class="radio-common selected">
                                <input type="radio" value="0" name="member_sex" checked="checked">
                            </i>
                            <span>{$Think.lang.member_edit_secret}</span>
                        </label>
                        <label class="radio-label">
                            <i  class="radio-common">
                                <input type="radio" value="1" name="member_sex">
                            </i>
                            <span>{$Think.lang.member_edit_male}</span>
                        </label>
                        <label class="radio-label">
                            <i  class="radio-common">
                                <input type="radio" value="2" name="member_sex">
                            </i>
                            <span>{$Think.lang.member_edit_female}</span>
                        </label>
                    </td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label for="member_qq">QQ:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_qq" name="member_qq" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required"><label for="member_qq">微信:</label></td>
                    <td class="vatop rowform"><input type="text" value="" id="member_wx" name="member_wx" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                <td class="required w150"><label  for="member_name">运营商编码:</label></td>
                <td class="vatop rowform"><input type="text"  name="operator_code" id="operator_code" class="txt">
                <td class="vatop tips">不填的话当前用户到默认运营商名下</td>
            </tr>
            </tbody>
            <tfoot>
                <tr class="tfoot">
                    <td colspan="15"><input class="btn" style="line-height: 10px;"  type="submit" value="{$Think.lang.ds_submit}"/></td>
                </tr>
            </tfoot>
        </table>
    </form>
</div>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script type="text/javascript">
                    //用户头像上传
                  $(document).on('change','#upload_img',function() {
                      var files = document.getElementById('upload_img').files[0];
                      var formData = new FormData();
                      formData.append('file',files);
                      layer.msg('正在上传，请稍后');
                      $.ajax({
                          //请求方式
                          type : "POST",
                          //请求地址
                          url : "ajax_upload",
                          data : formData,
                          cache:false,  //默认是true，但是一般不做缓存
                          processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                          contentType:false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                          //请求成功
                          success : function(result) {
                              if(result.err==0){
                                  layer.msg(result.msg);
                                  $('#portrait').val(result.data);
                              }else{
                                  $('#portrait').val('');
                                  alert('文件信息错误,请重新上传');return false;
                              }



                          },
                          //请求失败，包含具体的错误信息
                          error : function(e){
                              console.log(e.status);
                              console.log(e.responseText);
                          }
                      });

                  });
    $(function() {
        $("#member_address").ds_region();
    $("#business_licence_address").ds_region();
    $("#bank_address").ds_region();
    $("#settlement_bank_address").ds_region();
    $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
        $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});


        $('#user_form').validate({
            errorPlacement: function(error, element) {
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules: {
                member_name: {
                    required: true,
                    minlength: 11,
                    maxlength: 11,
                    remote: {
                        url: "{:url('Member/ajax',['branch'=>'check_user_name'])}",
                        type: 'get',
                        data: {
                            user_name: function() {
                                return $('#member_name').val();
                            },
                            member_id:'{$member_array.member_id|default=0}'
                        }
                    },
                     digits:true,
                },
                member_client: {
                    required: true,
                },
                member_password: {
                    required: true,
                    maxlength: 20,
                    minlength: 6
                },
                member_person_tel: {
                    required: true,
                    minlength: 11,
                    maxlength: 11,
                    digits:true,
                },
                contact_phone: {
                    required: true,
                    minlength: 11,
                    maxlength: 11,
                    digits:true,
                },
                member_nickname : {
                    required: true,
                    maxlength:8,
                },
                customer_name : {
                    required: true,
                },
                member_email: {
                    required: true,
                    email: true,
                    remote: {
                        url: "{:url('Member/ajax',['branch'=>'check_email'])}",
                        type: 'get',
                        data: {
                            user_name: function() {
                                return $('#member_email').val();
                            },
                            member_id: '{$member_array.member_id|default=0}'
                        }
                    }
                },
                member_qq: {
                    digits: true,
                    minlength: 5,
                    maxlength: 11
                },
                member_wx: {
                    digits: true,
                    minlength: 5,
                    maxlength: 11
                },
                operator_code: {
                    remote   : {
                        url :"{:url('Brand/ajax','branch=check_operator_code')}",
                        type:'get',
                        data:{
                            brand_name : function(){
                                return $('#operator_code').val();
                            },
                        }
                    }
                },
            },
            messages: {
                member_name: {
                    required: '{$Think.lang.member_add_name_null}',
                    maxlength: '请填写11位的手机号',
                    minlength: '请填写11位的手机号',
                    remote: '{$Think.lang.member_add_name_exists}',
                    digits:"请填写正确的手机号码"
                },
                member_client: {
                    required: '客户编码不能为空',
                },
                member_password: {
                    required: '{$Think.lang.password_add_name_null}',
                    maxlength: '{$Think.lang.member_edit_password_tip}',
                    minlength: '{$Think.lang.member_edit_password_tip}'
                },
                member_person_tel: {
                    required: '负责人联系方式不能为空',
                    maxlength: '请填写11位的手机号',
                    minlength: '请填写11位的手机号',
                    digits:"请填写正确的手机号码"
                },
                contact_phone: {
                    required: '联系人电话不能为空',
                    maxlength: '请填写11位的手机号',
                    minlength: '请填写11位的手机号',
                    digits:"请填写正确的手机号码"
                },
                member_nickname : {
                    required: '昵称不能为空',
                    maxlength:"昵称最长8位",
                },
                customer_name : {
                    required: '客户名称不能为空',
                },
                member_email: {
                    required: '{$Think.lang.member_edit_email_null}',
                    email: '{$Think.lang.member_edit_valid_email}',
                    remote: '{$Think.lang.member_edit_email_exists}'
                },
                member_qq: {
                    digits: '{$Think.lang.member_edit_qq_wrong}',
                    minlength: '{$Think.lang.member_edit_qq_wrong}',
                    maxlength: '{$Think.lang.member_edit_qq_wrong}'
                },
                member_wx: {
                    digits: '请输入正确的微信号',
                    minlength: '请输入正确的微信号',
                    maxlength: '请输入正确的微信号'
                },
                operator_code: {
                    remote   : '运营商编码输入不正确'
                },
            }
        });
    });
</script>
